package com.module.imagelib.glide;

import android.net.Uri;
import android.view.View;

import com.module.imagelib.glide.callback.ICallBack;
import com.module.imagelib.glide.progress.OnImageListener;

import java.io.File;

import androidx.annotation.DrawableRes;

/**
 * Created by dell on 2018/11/30
 */
public class LoaderOptions {
    public String url;
    public File file;
    public int drawableResId;
    public Uri uri;
    public int placeholderResId;
    public int errorResId;
    public boolean isCenterCrop;
    public boolean isCenterInside;
    public boolean isCircle;
    public boolean isFile; //下载原图
    public boolean isBitmap;
    public OnImageListener onImageListener;
    public boolean skipMemoryCache;
    public boolean skipDiskCache;
    public int bitmapWidth;
    public int bitmapHeight;
    public int bitmapAngle; //圆角角度
    public View targetView;//targetView展示图片
    public ICallBack callBack;


    public LoaderOptions(String url) {
        this.url = url;
    }

    public LoaderOptions(File file) {
        this.file = file;
    }

    public LoaderOptions(int drawableResId) {
        this.drawableResId = drawableResId;
    }

    public LoaderOptions(Uri uri) {
        this.uri = uri;
    }

    public void into(View targetView) {
        this.targetView = targetView;
        ImageLoader.getInstance().loadOptions(this);
    }

    public void into(ICallBack callBack) {
        this.callBack = callBack;
        ImageLoader.getInstance().loadOptions(this);
    }

    public LoaderOptions placeholder(@DrawableRes int placeholderResId) {
        this.placeholderResId = placeholderResId;
        return this;
    }

    public LoaderOptions error(@DrawableRes int errorResId) {
        this.errorResId = errorResId;
        return this;
    }

    public LoaderOptions centerCrop() {
        isCenterCrop = true;
        return this;
    }

    public LoaderOptions centerInside() {
        isCenterInside = true;
        return this;
    }

    public LoaderOptions circle() {
        this.isCircle = true;
        return this;
    }

    public LoaderOptions asFile() {
        this.isFile = true;
        return this;
    }

    public LoaderOptions asBitmap() {
        this.isBitmap = true;
        return this;
    }

    public LoaderOptions size(int bitmapWidth, int bitmapHeight) {
        this.bitmapWidth = bitmapWidth;
        this.bitmapHeight = bitmapHeight;
        return this;
    }

    /**
     * 圆角
     *
     * @param bitmapAngle 度数
     */
    public LoaderOptions round(int bitmapAngle) {
        this.bitmapAngle = bitmapAngle;
        return this;
    }

    public LoaderOptions skipMemoryCache(boolean skipMemoryCache) {
        this.skipMemoryCache = skipMemoryCache;
        return this;
    }

    public LoaderOptions skipDiskCache(boolean skipDiskCache) {
        this.skipDiskCache = skipDiskCache;
        return this;
    }


    public LoaderOptions progress(OnImageListener onImageListener) {
        this.onImageListener = onImageListener;
        return this;
    }



}
